from os.path import dirname, realpath, basename, join
from mg_app_framework import AppConfigBasic, AppType, RabbitMQConfigBasic, IdiServerConfigBasic

from common_bind_service.utils.msg import rabbitmq_message_key_to_handler, msg_dispatch


class ConfigStore(AppConfigBasic):
    # ==================== DON'T MODIFY THE CODE BETWEEN COMMENT LINE ====================

    work_dir = dirname(dirname(dirname(realpath(__file__))))
    app = basename(dirname(realpath(__file__)))
    log_path = join(work_dir, 'log', app + '.log')
    uuid_path = join(work_dir, '.appid')

    def get_module_dir(self):
        return dirname(realpath(__file__))

    def get_log_path(self):
        return self.log_path

    def get_uuid_path(self):
        return self.uuid_path

    def get_data(self):
        return self.data

    # ==================== DON'T MODIFY THE CODE BETWEEN COMMENT LINE ====================

    data = {
        'app_group': '测试应用组件',
        'app_name': '测试容器与转换服务',
        'app_type': AppType.user,
        'app_version': '1.0.0',
        'data': {}
    }

    def get_admin_host(self):
        return '192.168.20.191'

    def get_app_port(self):
        return 38822

    def connect_admin(self):
        return True

    # def organization_info(self):
    #     return {
    #         'code': 'lanjing'
    #     }


class RabbitMQConfig(RabbitMQConfigBasic):
    def publish_config_data(self):
        return False

    def get_rabbitmq_subscribe_list(self):
        return list(rabbitmq_message_key_to_handler.keys())

    def message_process_func(self):
        return msg_dispatch

    def ack_before_message_process_func(self):
        return False

    def set_qos_num(self):
        return 5

    # def get_rabbitmq_host(self):
    #     return '127.0.0.1'
    #
    # def get_rabbitmq_port(self):
    #     return 35672


    # def get_rabbitmq_username(self):
    #     return 'rabbitmq'
    #
    # def get_rabbitmq_password(self):
    #     return 'realtech@123'


class IdiServerConfigBasic1(IdiServerConfigBasic):
    pass
    # def get_mongodb_host(self):
    #     return '127.0.0.1'
    #
    # def get_mongodb_port(self):
    #     return '37017'
    #
    # def retry_interval(self):
    #     return 5